<!DOCTYPE html>
<html lang="zh-CN" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorator="layout/default" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <link th:href="@{/assets/css/statistics.css}" rel="stylesheet" type="text/css"/>
    <script th:src="@{/assets/scripts/statistics.js}"></script>
    <title>
        数据配置
    </title>
    <script>
        $(document).ready(function () {
            statistics.init();
            var count = '[[${#lists.size(statistics.statisticsTimes)}]]';
            if (count == 1) {
                $(".form-delete").hide();
            }
            else {
                $(".form-delete").show();
            }
        });

        function inputPlaceholderIn(element) {
            if (element.value == '请输入时间段名称') {
                $(element).val("");
                $(element).removeClass('placeholder-color');
            }
            else if (element.value == '起始时间') {
                $(element).val("");
                $(element).removeClass('placeholder-color');
            }
            else if (element.value == '结束时间') {
                $(element).val("");
                $(element).removeClass('placeholder-color');
            }
        }

        function namePlaceholderOut(element) {
            if (element.value.replace(/^\s+/, "").replace(/\s+$/, "") == "请输入时间段名称" || element.value.replace(/^\s+/, "").replace(/\s+$/, "") == "" || element.value.replace(/^\s+/, "").replace(/\s+$/, "") == null || element.value.replace(/^\s+/, "").replace(/\s+$/, "").length == 0) {
                $(element).val("请输入时间段名称");
                $(element).addClass('placeholder-color');
            }
        }

        function startPlaceholderOut(element) {
            if (element.value.replace(/^\s+/, "").replace(/\s+$/, "") == "起始时间" || element.value.replace(/^\s+/, "").replace(/\s+$/, "") == "" || element.value.replace(/^\s+/, "").replace(/\s+$/, "") == null || element.value.replace(/^\s+/, "").replace(/\s+$/, "").length == 0) {
                $(element).val("起始时间");
                $(element).addClass('placeholder-color');
            }
        }

        function endPlaceholderOut(element) {
            if (element.value.replace(/^\s+/, "").replace(/\s+$/, "") == "结束时间" || element.value.replace(/^\s+/, "").replace(/\s+$/, "") == "" || element.value.replace(/^\s+/, "").replace(/\s+$/, "") == null || element.value.replace(/^\s+/, "").replace(/\s+$/, "").length == 0) {
                $(element).val("结束时间");
                $(element).addClass('placeholder-color');
            }
        }
    </script>
</head>
<body>
<div layout:fragment="content" th:remove="tag">
    <div th:replace="fragments/tool :: tipMessage (type='',content=${message})" th:remove="tag"></div>
    <div class="row">
        <div class="col-md-12">
            <!-- BEGIN PAGE TITLE & BREADCRUMB-->
            <ul class="page-breadcrumb breadcrumb">
                <li>
                    <i class="fa fa-home"></i>
                    <a th:href="@{/}">首页</a>
                    <i class="fa fa-angle-right"></i>
                </li>
                <li>
                    <a href="#">配置管理</a>
                    <i class="fa fa-angle-right"></i>
                </li>
                <li>
                    <a href="#">数据配置</a>
                </li>
            </ul>
            <!-- END PAGE TITLE & BREADCRUMB-->
        </div>
    </div>

    <div class="row profile">
        <div class="col-md-10 content-center">
            <!--BEGIN TABS-->
            <div class="tab-content">
                <div class="tab-pane active" id="user_tab_1_2">
                    <div class="portlet box blue">
                        <div class="portlet-body form">
                            <!-- BEGIN FORM-->
                            <form th:action="@{/conf/statistics/save}" th:object="${statistics}"
                                  class="form-horizontal" id="configEditForm" method="post">
                                <div class="form-body form-p">
                                    <div class="form-group form-group-m">
                                        <label class="control-label form-text  alert-info">认证访问量时段配置</label>
                                    </div>
                                    <div id="md" class="form-group form-input form-group-m">
                                        <div th:each="statisticsTimes, stat : ${statistics.statisticsTimes}"
                                             class="form-group form-group-input" th:id="'div' + ${stat.index}">
                                            <input type="text" th:name="'statisticsTimes['+${stat.index} + '].name'"
                                                   onfocus="inputPlaceholderIn(this)"
                                                   onblur="namePlaceholderOut(this)"
                                                   th:classappend="${statisticsTimes.name} == '请输入时间段名称' ? 'placeholder-color' : ''"
                                                   class="form-input-c " maxlength="20"
                                                   th:value="${statisticsTimes.name}"/> &nbsp &nbsp 区间值（始）&nbsp &nbsp
                                            <input type="text" maxlength="5"
                                                   class="form-input-c "
                                                   th:classappend="${statisticsTimes.beginTime} == '起始时间' ? 'placeholder-color' : ''"
                                                   onfocus="inputPlaceholderIn(this)"
                                                   onblur="startPlaceholderOut(this)"
                                                   th:name="'statisticsTimes['+${stat.index} + '].beginTime'"
                                                   th:value="${statisticsTimes.beginTime}"/> &nbsp &nbsp区间值（末）&nbsp
                                            &nbsp
                                            <input type="text" th:name="'statisticsTimes['+${stat.index} + '].endTime'"
                                                   class="form-input-c " maxlength="5"
                                                   th:classappend="${statisticsTimes.endTime} == '结束时间' ? 'placeholder-color' : ''"
                                                   onfocus="inputPlaceholderIn(this)"
                                                   onblur="endPlaceholderOut(this)"
                                                   th:value="${statisticsTimes.endTime}"/> &nbsp
                                            <a class="btn btn-xs red-stripe" th:id="'deleteTime' + ${stat.index}"
                                               shiro:has-permission="sys:statistics:edit">删除</a>
                                            <br/>
                                        </div>
                                    </div>
                                    <div class="form-group form-group-add">
                                        <label class="btn-logo" shiro:has-permission="sys:statistics:edit">+</label>
                                        <input type="button" shiro:has-permission="sys:statistics:edit" class="btn greed btn-my" id="addBtn" value="自定义时间段"><br>
                                        <span class="form-livelyTime-text">（注：每条统计时间段必须为整数，所有时间段需在00:00~24:00范围内）</span>
                                    </div>
                                    <div class="form-group form-group-m device-martop">
                                        <label class="control-label form-text  alert-info">认证设备统计配置</label>
                                    </div>
                                    <div class="form-group form-group-m check-class">
                                        <label class="col-md-1 control-label form-text-2 form-label-minw">平台设备活跃时间</label>
                                        <input type="text" th:field="*{livelyTime}" maxlength="3"
                                               id="activeCount"
                                               onkeyup="this.value=this.value.replace(/\D/g,'')"
                                               onafterpaste="this.value=this.value.replace(/\D/g,'')"
                                               class="form-livelyTime form-input-c"/>
                                        <label class="col-md-4 control-label form-text-2 ">&nbsp 小时 <span
                                                class="form-livelyTime-text">（注：24~720小时之间）</span></label>
                                    </div>
                                    <div class="form-group form-group-m">
                                        <div class="border-line"></div>
                                    </div>
                                    <div class="form-group form-group-m">
                                        <label class="control-label form-text  alert-info">审计记录配置</label>
                                    </div>
                                    <div class="form-group form-group-m">
                                        <label class="col-md-1 control-label form-text-2 form-label-minw">审计数据</label>

                                        <div class="col-md-4">
                                            <div class="radio-list">
                                                <label class="radio-inline radio-c-my">
                                                    <input type="radio" th:name="recordStatus" th:value="0"
                                                           id="make"
                                                           th:checked="${statistics.recordStatus} == 0">
                                                    记录
                                                </label>
                                                <label class="radio-inline radio-c-my">
                                                    <input type="radio" th:name="recordStatus" th:value="1"
                                                           id="noMake"
                                                           th:checked="${statistics.recordStatus} == 1">
                                                    不记录
                                                </label>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group form-group-m check-class">
                                        <label class="col-md-1 control-label form-text-2 form-label-minw">
                                            审计迹最大值：</label>

                                        <div class="col-md-2 form-max">
                                            <input class="form-input-c" th:field="*{recordNumber}"
                                                   th:readonly="${statistics.recordStatus} == 1"
                                                   maxlength="7" id="maxCount"
                                                   onkeyup="this.value=this.value.replace(/\D/g,'')"
                                                   onafterpaste="this.value=this.value.replace(/\D/g,'')">
                                        </div>
                                    </div>
                                    <div class="form-group form-group-m check-class">
                                        <label class="col-md-1 control-label form-text-2 form-label-minw">
                                            审计迹告警值：</label>

                                        <div class="col-md-2 form-max">
                                            <input class="form-input-c" th:field="*{recordAlarm}"
                                                   maxlength="7" id="errorCount"
                                                   onkeyup="this.value=this.value.replace(/\D/g,'')"
                                                   th:readonly="${statistics.recordStatus} == 1"
                                                   onafterpaste="this.value=this.value.replace(/\D/g,'')">
                                        </div>
                                    </div>
                                </div>
                                <div class="form-actions fluid bottom-btn-r">
                                    <div class="col-md-12">
                                        <button type="button" value="default" shiro:has-permission="sys:statistics:edit"
                                                th:onclick="'javascript:location.href=\''+@{/conf/statistics/default}+'\''"
                                                class="btn green">恢 复
                                        </button>
                                        <button shiro:has-permission="sys:statistics:edit"
                                                type="submit" class="btn blue form-group-add btn-add-commit">保 存
                                        </button>
                                    </div>
                                </div>
                            </form>
                            <!-- END FORM-->
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>
